package com.woshua.svgmodel;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.woshua.svgmodel.utils.SvgShapeBitmapUtil;

import java.util.Random;

public class MainActivity extends AppCompatActivity {

    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView=findViewById(R.id.imageView);
    }

    public void shape(View view) {

        int[] resIds=new int[]
                {
                        R.raw.shape_one,
                        R.raw.shape_two,
                        R.raw.shape_three,
                };

        int resId=resIds[new Random().nextInt(resIds.length)];
        Bitmap meizi= BitmapFactory.decodeResource(getResources(),R.mipmap.mei_niu);
        Bitmap bitmap= SvgShapeBitmapUtil.getSvgShapeBitmap(this,meizi,resId);

        meizi.recycle();

        imageView.setImageBitmap(bitmap);
    }
}
